package com.cynteka.cyfoman.core.config;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * User: ukman
 * Date: 20.07.2011
 * Time: 20:48:47
 */
@XmlRootElement
public class ColumnMD {

    private String name;

    private String title;

    private String mask;

    private boolean visible = true;

    private Class columnClass = String.class;

    public Class getColumnClass() {
        return columnClass;
    }

    public void setColumnClass(Class columnClass) {
        this.columnClass = columnClass;
    }


    public ColumnMD() {
    }

    public ColumnMD(String name, String title) {
        this.name = name;
        this.title = title;
    }

    public ColumnMD(String name, String title, boolean visible) {
        this.name = name;
        this.title = title;
        this.visible = visible;
    }

    @XmlElement
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlElement
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }


    public boolean isVisible() {
        return visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    @Override
    public String toString() {
        return "ColumnMD{" +
                "name='" + name + '\'' +
                ", title='" + title + '\'' +
                ", mask='" + mask + '\'' +
                ", visible=" + visible +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ColumnMD columnMD = (ColumnMD) o;

        if (visible != columnMD.visible) return false;
        if (mask != null ? !mask.equals(columnMD.mask) : columnMD.mask != null) return false;
        if (name != null ? !name.equals(columnMD.name) : columnMD.name != null) return false;
        if (title != null ? !title.equals(columnMD.title) : columnMD.title != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (title != null ? title.hashCode() : 0);
        result = 31 * result + (mask != null ? mask.hashCode() : 0);
        result = 31 * result + (visible ? 1 : 0);
        return result;
    }

    public void setMask(String mask) {
        this.mask = mask;
    }

    @XmlElement
    public String getMask() {
        return mask;
    }
}
